
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>写评论</title>
		<style type="text/css">
		</style>
		<link rel="stylesheet" type="text/css" href="../../Resours/css/bootstrap.min.css">
	</head>
	
	<body>
			<div class="input-group">
		      <input type="text" class="form-control" placeholder="请输入评论..." id="evals" name="evals">
		      <span class="input-group-btn">
	      	</span>
      		</div>
		 <button class="btn btn-success"  onclick="submit()">提交评论</button>
	</body>
	<script type="text/javascript"
			src="../../Resours/js/jquery-3.3.1.min.js"></script>
		<script>
		function submit(){
			let evals = $("#evals").val();
			alert("eval"+evals);
			if (evals === "") {
				 alert("评论不能为空");
			}else{
					//进行ajax交互
					 $.ajax({
							method:'get',
							url:'/Shopx/UserServlet?action=writeeval',
							data:{'text': evals},
							success:function(data){
								if(data>0){
									alert("评论成功");
									window.close();
									history.back();
								}else if(data===0){
									alert('评论失败');
								}else if(data===-1){
									alert('评论前请先登录');
								}
							},
							dataType:'json'
			            });
			}
		}
		</script>
</html>